package 补充.String;

public class String类的初始化 {

    public static void main(String[] args) {
        //法1使用直接赋值初始化
        String sre1 ="holloword!";
        String sre2 ="holloword!";
        String sre3 ="hollo"+"word!";
        if (sre1==sre2) {
            System.out.println("相等");
        }else {
            System.out.println("不相等");
        }
        if (sre2==sre3) {
            System.out.println("相等");
        }else {
            System.out.println("不相等");
        }
        //使用构造方法初始化
        String S1=new String("holloword!");
        String S2=new String("holloword!");
        if (S1==S2) {
            System.out.println("相等");
        }else {
            System.out.println("不相等");
        }
        if (sre1==S2) {
            System.out.println("相等");
        }else {
            System.out.println("不相等");
        }
    }
}
